package com.xdf.ecommerce.order;

import com.xdf.ecommerce.goods.DeductGoodsInventory;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author chanchaw
 * @create 2025-11-11 16:09
 */
@ApiModel(description = "SDK中的订单info")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OrderInfo {
    @ApiModelProperty(value = "用户地址表主键 id")
    private Long userAddress;
    @ApiModelProperty(value = "订单中的商品数组")
    private List<OrderItem> orderItemList;

    @ApiModel(description = "SDK中的订单info中的商品信息")
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class OrderItem {
        @ApiModelProperty(value = "商品表主键 id")
        private Long goodsId;
        @ApiModelProperty(value = "商品的数量")
        private Integer count;
        // 扣减库存
        public DeductGoodsInventory toDeductGoodsInventory(){
            return new DeductGoodsInventory(this.goodsId, this.count);
        }
    }
}
